package com.shangyueshang.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.shangyueshang.model.Goods;
import com.shangyueshang.response.ShopSkuDTO;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @author: JokeyZheng
 * @email: zhengjingfeng@ruqimobility.com
 * @created: 2022/1/14 15:15
 * @version: v1.0.0
 */
@Component
public interface GoodsMapper extends BaseMapper<Goods> {


    /**
     * 根据店铺查询SKU信息
     *
     * @param shop
     * @return
     */
    @Select("<script>" +
            "SELECT " +
            "   g.shop, " +
            "   g.sku, " +
            "   g.name, " +
            "   g.goods_type as goodsType, " +
            "   g.product_code AS productCode, " +
            "   g.headway_fee AS headwayFee, " +
            "   p.purchase_cost AS purchaseCost, " +
            "   p.pack_cost AS packCost  " +
            "FROM " +
            "   goods g, " +
            "   product p " +
            "WHERE " +
            "   g.product_code = p.inner_code " +
            "AND g.shop = #{shop} " +
            "</script>")
    List<ShopSkuDTO> queryByShop(String shop);

}
